const jwt = require("jsonwebtoken")



let api_url="http://localhost:3000"
let secret="{++—？？：：：—）oa93434jc()%$[]（按时间安排进排气额派克服 是你福克斯}"
let tokenSecret="奥is发哦isDJ舞曲额容器"


// 加密token
function signToken(user){
  let token=jwt.sign(user,tokenSecret,{expiresIn:60*60})
  return token
}

// 解密token
function verifyToken(token) {
    try {
  
      let user = jwt.verify(token, tokenSecret)
      return [null,user]
  
    } catch (error) {

      return [error,undefined ]
  
    }
  
  }

module.exports={
    api_url,
    verifyToken,
    signToken,
    secret
}